<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" type="text/css" href="../../static/personal_center/css/index.css">
    <link rel="stylesheet" type="text/css" href="../../static/personal_center/css/common.css">
    <script type="text/javascript" src="../../static/personal_center/js/index.js"></script>
    <link rel="stylesheet" href="../../static/personal_center/font_2369197_oqktwkt71s/iconfont.css" media="screen">
    <link rel="stylesheet" href="../../static/public_file/css/PersonnelChooser.css">
    <style>
        .add_background {
            background: #A9A9A9;
        }
        .li-class {
            list-style: none;
            margin-top: 2%;
            color: #0b0b0b;
            cursor: pointer;
            height: 30px;
            line-height: 30px;
        }

        #loading {
            background: #fff url(../../static/public_file/images/jiazai.gif) no-repeat scroll center center;
            height: 100%; width: 100%; background-size: 10%; position: fixed; margin-top: 0px; top: 0px; left: 0px; bottom: 0px;
            overflow: hidden !important; right: 0px; z-index: 999999;background-color: rgba(255, 255, 255, 0.08);
        }
    </style>
</head>
<body>
    <div id="loading">
        <div id="loading-center">
        </div>
    </div>

    <div id="new_models1" class="shade">
        <div id="new_models" style="width: 100%;height: 100%;position: absolute;">
            <div style="width: 500px;height: 200px;background: #F5F5F5;z-index: 10000;position: absolute;top: 50%;left: 50%;transform:translate(-50%,-50%);border-radius: 3px;border: #dfdfdf solid 1px;">
                <div id="box" style="width: 100%;height: 40px;background: #f4f7fa;cursor: move;border-top-left-radius: 3px;border-top-right-radius: 3px;line-height: 40px;border-bottom: #dfdfdf solid 1px;">
                    <div style="width: 20%;margin-left: 1%;display: inline-block;line-height: 0px;font-size: 14px;">
                        流程节点修改
                    </div>
                    <span onclick="close_models()" style="float: right;padding-right: 2%;cursor: pointer;">
                        <i class="iconfont icon-quchu"></i>
                    </span>
                </div>
                <div style="height: 105px;width: 100%;border-bottom: #dfdfdf solid 1px;">
                    <div style="width: 100%;margin-left: 15px;margin-top: 15px;">
                        <label for="">选择节点: </label>
                        <select name="" id="node_select" style="width: 385px;height: 35px;border-radius: 3px;border: #cfcfcf solid 1px;outline: none;">
                        </select>
                    </div>

                    <div style="width: 100%;margin-top: 20px;margin-left: 15px;">
                        <label for="">审批人员: </label>
                        <input id="conferee" type="text" onclick="model_line()" style="width: 380px;height: 30px;border-radius: 3px;border: #cfcfcf solid 1px;outline: none;" autocomplete="off">
                    </div>
                </div>
                <div style="width: 100%;height: 40px;text-align: right;padding-right: 2%;">
                    <button id="summit_but" style="width: 100px;height: 30px;border: #dfdfdf solid 1px;margin-top: 5px;border-radius: 3px;background: #1E90FF;color: white;margin-right: 15px;">
                        提交
                    </button>
                </div>
            </div>
        </div>
    </div>

    <div style="width: 100%;height: 40px;border-bottom: #cfcfcf solid 1px;background: white;font-size: 0;text-align: right;padding-right: 15px;">
        <input type="text" id="search_value" name="search_val" style="width: 300px;display: inline-block;border-bottom-left-radius: 3px;border-top-left-radius: 3px;border: #0d8ddb solid 1px;vertical-align: top;font-size: 14px;padding-left: 2px;margin-top: 5px;height: 30px;outline: none;" placeholder="请输入搜索关键词">
        <button class="search-action" style="width: 100px;border-bottom-right-radius: 3px;border-top-right-radius: 3px;display: inline-block;font-size: 14px;border: #0d8ddb solid 1px;border-left: none;background: #0d8ddb;color: white;margin-top: 5px;height: 34px;margin-right: 15px;outline: none;cursor: pointer;">搜索</button>
    </div>

    <div style="width: 100%;height: 100%;background: white;">
        <div id="my_application" style="width: 100%;height: 100%;overflow: auto;background-color: white;">
            <div class="right-box" style="width: 100%;height: 100%;margin-top: 0;">
                <div style="height: 100%;width: 100%;overflow: auto;border-bottom: #cccccc solid 1px;background-color: white;">
                    <section class="grid-main" style="height: calc(100vh - 45px);">
                        <table id="main_table"></table>
                    </section>
                </div>
            </div>
        </div>
    </div>

    <script type="text/javascript" src="../../static/administrative/js/other/jquery.js"></script>
    <script type="text/javascript" src="../../static/public_file/js/PersonnelChoosersNew.js" charset="gb2312"></script>
    <script>
        const gridManagerName = "test",
        TYPE_MAP = {1: "HTML/CSS", 2: "nodeJS", 3: "javaScript", 4: "前端鸡汤", 5: "PM Coffee", 6: "前端框架", 7: "前端相关"},
        GM_PUBLISH_METHOD_MAP = {
            init: {key: "init", relyInit: !1, title: "初始化", code: 'demo1.initGM(document.querySelector("table"));'},
            get: {key: "get", relyInit: !0, title: "获取表格的实时配置信息", code: `GridManager.get('${gridManagerName}');`},
            version: {key: "version", relyInit: !1, title: "获取当前GridManager的版本号", code: "GridManager.version;"},
            getLocalStorage: {
                key: "getLocalStorage",
                relyInit: !0,
                title: "获取表格用户记忆",
                code: `GridManager.getLocalStorage('${gridManagerName}');`
            },
            resetLayout: {
                key: "resetLayout",
                relyInit: !0,
                title: "重置表格布局",
                code: `GridManager.resetLayout('${gridManagerName}', '800px', '500px');`
            },
            clear: {
                key: "clear",
                relyInit: !0,
                title: "清除表格记忆数据",
                code: `GridManager.clear('${gridManagerName}');`
            },
            getTableData: {
                key: "getTableData",
                relyInit: !0,
                title: "获取指定tr所使用的数据",
                code: `GridManager.getTableData('${gridManagerName}');`
            },
            getRowData: {
                key: "getRowData",
                relyInit: !0,
                title: "获取指定tr所使用的数据",
                code: `GridManager.getRowData('${gridManagerName}', document.querySelector("table[grid-manager=${gridManagerName}] tbody tr"));`
            },
            updateRowData: {
                key: "updateRowData",
                relyInit: !0,
                title: "更新指定行所使用的数据",
                code: `GridManager.updateRowData('${gridManagerName}', 'id', {id: 112, title: 'ccc'});`
            },
            updateTreeState: {
                key: "updateTreeState",
                relyInit: !0,
                title: "更新树的展开状态",
                code: `GridManager.updateTreeState('${gridManagerName}', true);`
            },
            setSort: {
                key: "setSort",
                relyInit: !0,
                title: "手动设置排序",
                code: `GridManager.setSort('${gridManagerName}', {createDate: 'ASC'});`
            },
            setConfigVisible: {
                key: "setConfigVisible",
                relyInit: !0,
                title: "设置表头配置区域可视状态",
                code: `GridManager.setConfigVisible('${gridManagerName}', true);`
            },
            setLineHeight: {
                key: "setLineHeight",
                relyInit: !0,
                title: "配置行的高度",
                code: `GridManager.setLineHeight('${gridManagerName}', '70px');`
            },
            showTh: {
                key: "showTh",
                relyInit: !0,
                title: "设置列为可视状态",
                code: `GridManager.showTh('${gridManagerName}', 'pic');`
            },
            hideTh: {
                key: "hideTh",
                relyInit: !0,
                title: "设置列为隐藏状态",
                code: `GridManager.hideTh('${gridManagerName}', 'pic');`
            },
            exportGrid: {
                key: "exportGrid",
                relyInit: !0,
                title: "导出指定表格",
                code: `GridManager.exportGrid('${gridManagerName}', 'demo中使用的导出').then(res=>{console.log('success')}).catch(err=>{console.error('error', err)});`
            },
            setQuery: {
                key: "setQuery",
                relyInit: !0,
                title: "更改在生成组件时所配置的参数query",
                code: `GridManager.setQuery('${gridManagerName}', {'userName':'baukh','sex':'男'});`
            },
            setAjaxData: {
                key: "setAjaxData",
                relyInit: !0,
                title: "用于再次配置ajaxData数据",
                code: `GridManager.setAjaxData('${gridManagerName}', {data: [{title: '通过setAjaxData动态添加的数据，其它项为空'}], totals: 1});`
            },
            refreshGrid: {
                key: "refreshGrid",
                relyInit: !0,
                title: "刷新表格",
                code: `GridManager.refreshGrid('${gridManagerName}');`
            },
            renderGrid: {
                key: "renderGrid",
                relyInit: !0,
                title: "渲染表格",
                code: `GridManager.renderGrid('${gridManagerName}');`
            },
            getCheckedTr: {
                key: "getCheckedTr",
                relyInit: !0,
                title: "获取当前选中的行",
                code: `GridManager.getCheckedTr('${gridManagerName}');`
            },
            getCheckedData: {
                key: "getCheckedData",
                relyInit: !0,
                title: "获取选中行的渲染数据",
                code: `GridManager.getCheckedData('${gridManagerName}');`
            },
            setCheckedData: {
                key: "setCheckedData",
                relyInit: !0,
                title: "设置选中的数据",
                code: `GridManager.setCheckedData('${gridManagerName}', [GridManager.getTableData('${gridManagerName}')[1]]);`
            },
            cleanData: {
                key: "cleanData",
                relyInit: !0,
                title: "清除指定表格数据",
                code: `GridManager.cleanData('${gridManagerName}');`
            },
            print: {key: "print", relyInit: !0, title: "打印当前页", code: `GridManager.print('${gridManagerName}');`},
            showRow: {
                key: "showRow",
                relyInit: !0,
                title: "显示隐藏行",
                code: `GridManager.showRow('${gridManagerName}', 1);`
            },
            hideRow: {
                key: "hideRow",
                relyInit: !0,
                title: "隐藏行",
                code: `GridManager.hideRow('${gridManagerName}', 1);`
            },
            showLoading: {
                key: "showLoading",
                relyInit: !0,
                title: "显示加载中",
                code: `GridManager.showLoading('${gridManagerName}');`
            },
            hideLoading: {
                key: "hideLoading",
                relyInit: !0,
                title: "隐藏加载中",
                code: `GridManager.hideLoading('${gridManagerName}', 300);`
            },
            destroy: {
                key: "destroy",
                relyInit: !0,
                title: "消毁指定的GridManager实例",
                code: `GridManager.destroy('${gridManagerName}');`
            }
        }, arg = {
            gridManagerName: "test",
            width: "100%",
            height: "100%",
            autoOrderConfig: {fixed: "left"},
            checkboxConfig: {key: "id", fixed: "left"},
            supportAjaxPage: !0,
            sortMode: "single",
            supportMenu: !0,
            menuHandler: e => (e.unshift({
                content: "自定义菜单", line: !0, onClick: e => {
                    alert(e)
                }
            }), e),
            useCellFocus: !0,
            useHideRow: !0,
            supportMoveRow: !0,
            moveRowConfig: {
                key: "priority", useSingleMode: !0, fixed: "left", handler: (e, t) => {
                    console.log(e, t)
                }
            },
            disableCache: !1,
            ajaxData: function (e, t) {
                var local_host = window.location.host;          // 获取当前IP
                return "/back-management/ContractCountersignatureList.html"
            },
            exportConfig: {
                fileName: e => {
                    const t = new Date;
                    let a = `${t.getFullYear()}-${t.getMonth() + 1}-${t.getDate()}`;
                    for (let t in e) a = `${a}-${t}=${e[t]}`;
                    return a
                }, suffix: "xls"
            },
            ajaxType: "POST",
            checkedBefore: function (e, t, a) {
                return console.log("checkedBefore==", e, t, a), a && 90 === a.id && alert("该节点在checkedBefore中配置为不可选"), a && 90 !== a.id
            },
            checkedAfter: function (e, t, a) {
                console.log("checkedAfter==", e, t, a)
            },
            checkedAllBefore: function (e, t) {
                console.log("checkedAllBefore==", e, t)
            },
            checkedAllAfter: function (e, t) {
                console.log("checkedAllAfter==", e, t)

            },
            sortingBefore: function (e) {
                console.log("sortingBefore", e)
            },
            sortingAfter: function (e) {
                console.log("sortingAfter", e)
            },
            ajaxBeforeSend: function (e) {
                console.log("ajaxBeforeSend")
            },
            ajaxSuccess: function (e) {
                document.getElementById("loading").style.display = "none";
                console.log("ajaxSuccess")
            },
            ajaxError: function (e) {
                console.log("ajaxError")
            },
            ajaxComplete: function (e) {
                console.log("ajaxComplete")
            },
            adjustBefore: e => {
                console.log("adjustBefore=>", e)
            },
            adjustAfter: e => {
                console.log("adjustAfter=>", e)
            },
            responseHandler: e => (e.data.forEach((e => {
                e.priority = e.id
            })), e),
            rowRenderHandler: (e, t) => e,
            emptyTemplate: e => `<div style="text-align: center;">${e.query.title ? "搜索为空" : "暂无数据"}</div>`,
            columnData: [
                {
                    key: "apply_user",
                    text: "申请人",
                    align: "center",
                }, {
                    key: "company",
                    text: "申请科室",
                    align: "center",
                }, {
                    key: "create_time",
                    text: "申请时间",
                    align: "center",
                }, {
                    key: "contract_name",
                    text: "合同名称",
                    align: "center",
                }, {
                    key: "contract_number",
                    text: "合同编号",
                    align: "center",
                }, {
                    key: "contract_type",
                    text: "合同类型",
                    align: "center",
                }, {
                    key: "state_display",
                    text: "状态",
                    align: "center",
                }, {
                    key: "current_audit_users",
                    text: "审批人",
                    align: "center",
                },{
                    key: "action",
                    width: "150px",
                    align: "center",
                    fixed: "right",
                    disableMoveRow: !0,
                    disableRowCheck: !0,
                    text: '<span style="color: red">操作</span>',
                    template: (e, t) => `<a class="plugin-action" href="${t.url}">查看</a>`
                }]
        }, demo1 = {
            initSearch: function () {
                document.querySelector(".search-action").addEventListener("click", (function () {
                    var data_value = document.getElementById("search_value").value;
                    var e = {
                        search_data: data_value,
                    };
                    table.GM("setQuery", e, (function () {
                        console.log("setQuery执行成功")
                    }))
                 }))
            }, initFN: () => {

            }, initGM: function () {
                new window.GridManager(table, arg, (e => {
                    console.log("渲染完成后的回调函数:", e), console.log(arg.columnData)
                }))
            }, editRowData: function (e) {
                window.GridManager.updateRowData("test", "id", {
                    id: window.parseInt(e.getAttribute("data-id")),
                    lastDate: (new Date).getTime()
                })
            }
        }, table = document.querySelector("#main_table");
        demo1.initSearch(table), demo1.initGM(table), demo1.initFN();

        let title = document.querySelector("#box");
        let addForm = document.querySelector("#new_models");
        title.addEventListener("mousedown", function (e) {
            let x = e.pageX - addForm.offsetLeft;
            let y = e.pageY - addForm.offsetTop;

            document.addEventListener("mousemove", move);
            function move(e) {
                addForm.style.left = e.pageX - x + 'px';
                addForm.style.top = e.pageY - y + 'px';
            }

            document.addEventListener("mouseup", function (e) {
                document.removeEventListener("mousemove", move);
            })
        });

        function line_models(RegularId) {
            document.getElementById("new_models2").style.display = "table-row";
            document.getElementById("summit_but2").setAttribute("onclick", "delete_topic('"+String(RegularId)+"')")
        }

        function close_models3() {
            document.getElementById("new_models2").style.display = "none";
        }

        function delete_topic(ContractId) {
            document.getElementById("loading").style.display = "inline-block";
            var xhr = new XMLHttpRequest();
            var local_host = window.location.host;          // 获取当前IP
            xhr.open('post', "/back-management/ContractCountersignatureDetail.html", true);
            xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
            xhr.send("ContractId="+String(ContractId)+"&type=delete");
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        document.getElementById("loading").style.display = "none";
                        var JsonDate = JSON.parse(xhr.responseText);
                        if (JsonDate['code'] === 200) {
                            console.log('JsonDate', JsonDate)
                            alert('删除成功')
                            window.location.reload();
                        } else {
                            alert(JsonDate['message'])
                            window.location.reload();
                        }

                    }
                }
             }
        }

        function online_tag(ele_id, status) {
            document.getElementById("new_models1").style.display = "table-row";
            document.getElementById("summit_but").setAttribute("onclick", 'do_back('+ele_id+')');
            var node_dict = {"one": "科室负责人", "two": "物资需求科室负责人", "three": "财务科负责人", "four": "监察室负责人", "five": "审计科负责人", "six": "分管领导审核", "nine": "书记/院长审核", "ten": "法人审核", "eleven": "党政办审核盖章", "eight": "拒绝"}
            var change_state = document.getElementById("node_select");
            change_state.innerHTML="";
            for (i in node_dict) {
                var option = document.createElement("option");
                option.value=i;option.innerHTML=node_dict[i];
                if (status === node_dict[i]) {
                    option.selected=true
                }
                change_state.appendChild(option);
            }
        }

        function do_back(id){
            var change_state = document.getElementById("node_select");
            var state_index = change_state.selectedIndex;
            var state = change_state.options[state_index].value;
            var audit_people = document.getElementById("conferee").value;
            var xhr = new XMLHttpRequest();
            var local_host = window.location.host;          // 获取当前IP
            xhr.open('post', "/back-management/ContractCountersignatureDetail.html", true);
            xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
            xhr.send("ContractId="+String(id)+"&type=revise"+"&state="+String(state)+"&audit_people="+String(audit_people));
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        var JsonDate = JSON.parse(xhr.responseText);
                        if (JsonDate['code'] === 200) {
                            console.log('JsonDate', JsonDate)
                            alert('退回成功')
                            window.location.reload();
                        } else {
                            alert(JsonDate['message'])
                            window.location.reload();
                        }

                    }
                }
            }
        }

        function close_models() {
            document.getElementById("new_models1").style.display = "none";
        }

        function scrollConversationScreen() {
            $('#selected-div').scrollTop($('#selected-div')[0].scrollHeight);
        }

        function IdentifyPersonnel() {
            var prople_list = [];
            var selected_personnel_list = document.getElementsByClassName('selected-personnel');
            for (var i=0; i<selected_personnel_list.length; i++) {
                prople_list.push(selected_personnel_list[i].innerText)
            }
            document.getElementById("conferee").value = prople_list.join();
            close_model()
        }
    </script>
</body>
</html>